<?
$char = strtoupper(substr(str_shuffle('abcdefghjkmnpqrstuvwxyz'), 0, 4));

// Concatenate the random string onto the random numbers
// The font 'Anorexia' doesn't have a character for '8', so the numbers will only go up to 7
// '0' is left out to avoid confusion with 'O'
$str = rand(1, 7) . rand(1, 7) . $char;
//session_start();

// Set the session contents
$_SESSION['captcha_id'] = $str;

?>
	<link rel="stylesheet" type="text/css" media="screen,print" href="styles/main.css" />
    <script type="text/javascript" src="js/jquery-1.8.0.min.js" ></script>
    <script type="text/javascript" src="js/jquery.validate.min.js"></script>
<style type="text/css">
		.error {
			border: solid 1px red;
		}
		.error label{
			border: solid 0px red;
		}
	</style>
    <script type="text/javascript">
    	$(window).ready(function(){
    		$.validator.methods.isname = function(value,element,param) {
    			var pattern = /^(\w){3,100}$/i;
    			if(pattern.test(value)==param || value=="")
    				return true;
    			else
    				return false;
    		};
    		$.validator.methods.isrsocial = function(value,element,param) {
    			var pattern = /^(\w){1,100}$/i;
    			if(pattern.test(value)==param|| value=="")
    				return true;
    			else
    				return false;
    		};
    		$.validator.methods.phone = function(value,element,param) {
    			var pattern = /^0[123456789](\d){8,8}$/i;
    			if(pattern.test(value)==param || value=="")
    				return true;
    			else
    				return false;
    		};
    		
    		$('#registration').validate({
    			onfocusout:false,
    			onkeyup:false,
    			rules:{
    				salutation:{required:true},
    				firstname:{required:true,isname:true},
    				lastname:{required:true,isname:true},
    				rsocial:{required:false,isrsocial:true},
    				phone:{required:false,phone:true},
    				email:{required:true,email:true},
    				captcha:{required:true,remote:"accueil_files/captcha/process.php"}
    				
    			},
    			messages:{
    				salutation:"*",
    				firstname:"*",
    				lastname:"*",
    				rsocial:"*",
    				phone:"*",
    				email:"*",
    				captcha:"*"
    			}
    		});
    		
    		$("#message").focus(function(e){
    			e.stopImmediatePropagation(); 
    			if($(this).val()=="Votre message") {
    				$(this).val("");
    			}
    		
    		});
    		$("#message").click(function(e){
    			e.stopImmediatePropagation(); 
    			if($(this).val()=="Votre message") {
    				$(this).val("");
    			}
    		
    		});
    	});
    </script>

<div style="height: 60px;">&nbsp;</div>
	<div style="font-size:20px;font-family: Arial;margin-bottom: 15px;">Pour plus de renseignements ou <br/>nous rencontrer, contactez nous</div>
          	<div>
<form id="registration" name="registration" method="post" action="accueil.php" target="_top">
            	<div class="formitem">
            		<div class="label" style="float: left;"><label>votre civilit&#233; *</label><label for="salutation" class="error" style="display: none;width:5px;border:0px;">*</label></div>
            		<div style="float: left;">
            			<font style="color:grey">M</font> <input type="radio" name="salutation" value="M" />
            			<font style="color:grey">Mme</font> <input type="radio" name="salutation" value="Mme" />
            			<font style="color:grey">Mlle</font> <input type="radio" name="salutation" value="Mlle" /> 
            		</div>
            	</div>
            	<div class="formitem">
            		<div class="label"><label>votre pr&#233;nom *</label><label for="firstname" class="error" style="display: none;width:5px;border:0px;"></label></div>
            		<div><input type="text" name="firstname" value="" /></div>
            	</div>
            	<div class="formitem">
            		<div class="label"><label>votre nom *</label><label for="lastname" class="error" style="display: none;width:5px;border:0px;"></label></div>
            		<div><input type="text" name="lastname" value="" /></div>
            	</div>
            	<div class="formitem">
            		<div class="label"><label>votre raison sociale</label><label for="rsocial" class="error" style="display: none;width:5px;border:0px;"></label></div>
            		<div><input type="text" name="rsocial" value="" /></div>
            	</div>
            	<div class="formitem">
            		<div class="label"><label>votre t&#233;l&#233;phone</label><label for="phone" class="error" style="display: none;width:5px;border:0px;"></label></div>
            		<div><input type="text" name="phone" value="" /></div>
            	</div>
            	<div class="formitem">
            		<div class="label"><label>votre email *</label><label for="email" class="error" style="display: none;width:5px;border:0px;"></label></div>
            		<div><input type="text" name="email" value="" /></div>
            	</div>
            	<div class="formitem">
            		<div>merci de recopier le texte pr&#233;sent dans l'image <label for="captcha" class="error" style="display: none;width:5px;border:0px;"></label></div>
            		<div class="label"><img src="/test/accueil_files/captcha/images/image.php?<?echo time();?>" width="132" height="46" alt="Captcha image" /></div>
            		<div><input type="text" name="captcha" id="captcha" value="" maxlength="6"/></div>
            	</div>
            	<div style="clear:both;">
            		<div><label>votre message</label></div>
            		<div style="width: 100%"><textarea name="message" id="message"  rows="5">Votre message</textarea></div>
            	</div>
            	<div style="text-align: center;width: 100%;display: block;">
            		<input type="image" src="accueil_files/envoyer.png" id="valider" value="Valider" />
            	</div>
            </form>
            </div>
